Address Translation: Segmentation

Table of Contents

Memory management is a joint effort that hardwares are involved for address translation, and there’re extra mechanism to keep track of free locations to allocate, usually free list, a list of the ranges of the physical memory which are not currently in use.

Address translation transforms the virtual address (which is generated by the process) into a physical address at which the desired information is actually located.

1. Memory Management Unit and Address Space

In process’s perspective, its address space starts from \(0\). But in OS’ perspective, its address space could start at anywhere.

1.1. Base and Bound

Thus, the OS need \(2\) pointers (registers) to represent the physical space that a process takes up: base pointer and bound pointer. The former stores the beginning physical address of the process’s address space, while the latter stores the size of that address space (to prevent the process from accessing invalid memory). These \(2\) registers are kept on chips, and are usually referred to as memory management unit (MMU). So at simplest situation, the address translation can be expressed as \( \text{physical} = \text{virtual} + \texttt{base} \).

Adding to Trap Mechanism and Context Switch, the base and bound registers must be also stored to the process structure, or the process control block, by OS.

And also add up to Trap Mechanism and Context Switch, when restoring process, OS now must copy the address space away from RAM; upon restore, it must be copied back to RAM again.

1.2. Segmentation

We further generalize base-and-bound method to segmentation. The idea of segmentation is: we have a base and bound pair per logical segment of the (virtual) address space. Now that, even for a large address space, we can independently treat each segment, such that if the process does not access a segment, OS does not allocate RAM to this segment.

With segmentation, we can support code sharing through extra protective bits in virtual address which indicates permission.

Segmentation also has its own problem. First, if there’re too many segments, we probably need segment table to maintain the position of each segment. Second, although this method reduces internal fragment, it introduces external fragment. This gives birth to free space management.

Date: 2026-07-20 Mon